﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace F1010DB
{
    public class SqlBuilderBasical
    {
        private string[] arrColumn = null;
        private string tableName = string.Empty;
        private string[] arrParameters = null;

        public SqlBuilderBasical()
        {

        }

        public SqlBuilderBasical(string[] arrColumn, string tableName, string[] arrParameters)
        {
            this.arrColumn = arrColumn;
            this.tableName = tableName;
            this.arrParameters = arrParameters;
        }

        public string setInsertSQLStatement()
        {
            if (arrColumn.Length == 0 || arrParameters.Length == 0 || tableName == string.Empty)
            {
                return string.Empty;
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(" INSERT INTO " + tableName + "(");

            for (int i = 0; i < arrColumn.Length; i++)
            {
                sb.AppendLine(arrColumn[i]);

                if (i != arrColumn.Length - 1)
                {
                    sb.Append(",");
                }
            }

            sb.AppendLine(")");
            sb.AppendLine(" VALUES(");

            for (int i = 0; i < arrParameters.Length; i++)
            {
                sb.AppendLine(arrParameters[i]);

                if (i != arrParameters.Length - 1)
                {
                    sb.Append(",");
                }
            }

            sb.AppendLine(")");

            return sb.ToString();
        }
    }
}
